**********************************************************************************************
* Reproduces Table 2
*
* Ajzenman, Elacqua, Jaimovich and Pérez-Núñez (2024)."Humans versus Chatbots: Scaling-up behavioral interventions to reduce teacher shortages"  	  		
*
**********************************************************************************************

matrix drop _all

mat D=J(26,5,.)
local i= 1
local j= 2

* balance check for interesed in education 
foreach var in sexo municipal subvencionado particular top_30 agno_egreso prom_notas ptje_ranking prom_cm_actual padres_incompleta padres_media_completa padres_superior bajo_linea_pobreza{
	
sum `var' if grupo_det== "Humano"
mat D[`i',1]= r(mean)
mat D[`j',1]= r(sd)

sum `var' if grupo_det== "Bot A"
mat D[`i',2]= r(mean)
mat D[`j',2]= r(sd)

sum `var' if grupo_det== "Control A"
mat D[`i',3]= r(mean)
mat D[`j',3]= r(sd)

*ttest human vs control interesed in education
preserve
drop if education_preference==0
drop if grupo_det=="Bot A"
ttest `var' , by(grupo_det) 
mat D[`i',4]=  r(mu_2) - r(mu_1)
restore 

*ttest bot vs control interesed in education
preserve
drop if education_preference==0
drop if grupo_det=="Humano"
ttest `var' , by(grupo_det) 
mat D[`i',5]= r(mu_1) - r(mu_2)
restore 

local i =`i'+2
local j =`j'+2
}

matlist D

mat rownames D= "Female" "." "Public" "." "Private-Subsidized" "." "Private" "." "High school GPA, top 30%" "." "Recent year graduation"  "." "High school GPA" "." "High school ranking score" "." "Average math and verbal test" "." "Parents without high school" "." "Parents with high school" "." "Parents with higher education" "." "Low income family" "."

mat colnames D= "Human" "Bot" "Control" "Human vs Control"  "Bot vs Control"

matlist D

frmttable using "${output}/Table2.tex", statmat(D) varlabels replace sdec(0,3,3,0,0,0) tex fr
